package com.http.filterlianxi;

import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;

@WebServlet(name = "RegisterServlet", value = "/RegisterServlet")
public class RegisterServlet extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        // 获取注册表单提交的用户名密码
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        // 将用户名密码设置进session的属性
        HttpSession session = request.getSession();
        session.setAttribute("username", username);
        session.setAttribute("password", password);
        // 重定向到登录页面
        response.sendRedirect("/pub/login.html");
    }

    public void destroy() {
    }
}